home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Environments
/
PowerLisp 2.01
/
PowerLisp 2.01 ƒ
/
examples
/
primes.lisp
< prev
Wrap
Lisp/Scheme
|
1995-03-09
|
484b
|
22 lines
;
; File: primes.lisp
; Contents: Lisp program to generate all the prime numbers
; between 1 and n. It is quick and dirty, and uses
; a brute force approach to calculating them (i.e. it
; tries all possibilites).
;
(defun primes (n1 n2)
"Generate all the prime numbers between n1 and n2"
(do ((i n1 (1+ i)))
((> i n2))
(block inner
(do ((j 2 (1+ j)))
((>= j i) (print i))
(if (zerop (mod i j)) ; if found a divisor
(return-from inner))))))